//
//  qlPreviewController.m
//  HappyStore
//
//  Created by 李小辉 on 16/8/22.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "qlPreviewController.h"

@interface qlPreviewController ()<QLPreviewControllerDataSource,QLPreviewControllerDelegate>

@end

@implementation qlPreviewController



- (void)viewDidLoad {
    [super viewDidLoad];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 190, 44)];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.font = [UIFont systemFontOfSize:19];
    if ([self.chickStr isEqualToString:@"关于我们"]) {
        titleLabel.text = @"关于我们";
    }else{//用户协议
        titleLabel.text = @"乐商网用户使用协议";
    }
    
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = titleLabel;
    
    self.delegate = self;
    self.dataSource  = self;
    //设置返回按钮

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller{
    return 1;
}
- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index{
    NSString *pathStr = @"";
    if ([self.chickStr isEqualToString:@"关于我们"]) {
        pathStr = [[NSBundle mainBundle] pathForResource:@"关于我们" ofType:@"pages"];
    }else{//用户协议
        pathStr = [[NSBundle mainBundle] pathForResource:@"乐商网用户使用协议" ofType:@"doc"];
    }
    
    NSURL *myQLDocument = [NSURL fileURLWithPath:pathStr];
    
    return myQLDocument;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
